import http from '@/utils/http'

const BASE_URL = '/task/deviceInfo'

export interface DeviceInfoResp {
  id: string
  name: string
  category: string
  managementNumber: string
  modelNumber: string
  factoryNumber: string
  measureUnit: string
  count: string
  status: string
  location: string
  source: string
  buyDate: string
  manufacturer: string
  purchaseAmount: string
  mark: string
  destination: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface DeviceInfoDetailResp {
  id: string
  name: string
  category: string
  managementNumber: string
  modelNumber: string
  factoryNumber: string
  measureUnit: string
  count: string
  status: string
  location: string
  source: string
  buyDate: string
  manufacturer: string
  purchaseAmount: string
  mark: string
  destination: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface DeviceInfoQuery {
  name: string
  category: string
  managementNumber: string
  modelNumber: string
  factoryNumber: string
  measureUnit: string
  count: string
  status: string
  location: string
  source: string
  buyDate: string
  manufacturer: string
  purchaseAmount: string
  mark: string
  destination: string
  createUser: string
  createTime: string
  sort: Array<string>
}
export interface DeviceInfoPageQuery extends DeviceInfoQuery, PageQuery {}

/** @desc 查询设备资源列表 */
export function listDeviceInfo(query: DeviceInfoPageQuery) {
  return http.get<PageRes<DeviceInfoResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询设备资源详情 */
export function getDeviceInfo(id: string) {
  return http.get<DeviceInfoDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增设备资源 */
export function addDeviceInfo(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改设备资源 */
export function updateDeviceInfo(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除设备资源 */
export function deleteDeviceInfo(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出设备资源 */
export function exportDeviceInfo(query: DeviceInfoQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
